#include "stdafx.h"
#include "include/IReferenced.h"
#include "../Managed.h"

namespace Gs
{
	// Initialises a new instance of the Managed class.
	Managed::Managed()
		: _next(0), _state(Indeterminate)
	{
	}

	// Destroys the instance.
	Managed::~Managed()
	{
	}

	// Initialises a new instance of the IReferenced class.
	IReferenced::IReferenced()
		: _referenceCount(1)
	{
	}

	// Destroys the IReferenced instance.
	IReferenced::~IReferenced()
	{
	}

	// Retains a reference to the instance.
	void IReferenced::Retain()
	{
		++_referenceCount;
	}

	// Releases a reference to the instance.
	void IReferenced::Release()
	{
		if (!--_referenceCount)
			delete this;
	}

	// Returns the number of references to the instance.
	int IReferenced::ReferenceCount()
	{
		return _referenceCount;
	}
}